#    SUSAN® - Sole of Unix Save ANything
#
#   Copyright (C) 2017-2020 Hechzh Property
#
#   This program is Free Software; you can redistribute it and/or
#   modify it under the terms of version three of the GNU Affero General Public
#   License as published by the Free Software Foundation and included
#   in the file LICENSE.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#   02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

set(BSMTPSRCS bsmtp.cc)
if(HAVE_WIN32)
  list(APPEND BSMTPSRCS ../win32/tools/bsmtpres.rc)
endif()
add_executable(bsmtp ${BSMTPSRCS})
target_link_libraries(bsmtp susan ${JANSSON_LIBRARIES})

add_executable(drivetype drivetype.cc)
target_link_libraries(drivetype susan susanfind ${JANSSON_LIBRARIES})

add_executable(fstype fstype.cc)
target_link_libraries(fstype susan susanfind ${JANSSON_LIBRARIES})

set(BREGEXSRCS bregex.cc)
if(HAVE_WIN32)
  list(APPEND BREGEXSRCS ../win32/tools/bregexres.rc)
endif()
add_executable(bregex ${BREGEXSRCS})
target_link_libraries(bregex susan susanfind ${JANSSON_LIBRARIES})

set(BWILDSRCS bwild.cc)
if(HAVE_WIN32)
  list(APPEND BWILDSRCS ../win32/tools/bwildres.rc)
endif()
add_executable(bwild ${BWILDSRCS})
target_link_libraries(bwild susan ${JANSSON_LIBRARIES})

add_executable(bscrypto bscrypto.cc)
target_link_libraries(bscrypto susan ${JANSSON_LIBRARIES})

if(NOT HAVE_WIN32)

  add_executable(btestls btestls.cc)
  target_link_libraries(btestls susanfind susan ${JANSSON_LIBRARIES})

  add_executable(bpluginfo bpluginfo.cc)
  target_link_libraries(bpluginfo susan ${DL_LIBRARIES} ${JANSSON_LIBRARIES})

  add_executable(timelimit timelimit.cc)
endif()

set(TOOLS_BIN bsmtp bwild bregex)

set(TOOLS_SBIN bscrypto bwild bregex)

if(NOT HAVE_WIN32)
  list(APPEND TOOLS_BIN timelimit)
  list(APPEND TOOLS_SBIN bpluginfo timelimit btestls)
endif()

install(TARGETS ${TOOLS_BIN} DESTINATION "${bindir}")
install(TARGETS ${TOOLS_SBIN} DESTINATION "${sbindir}")

# install bsmtp for non-root directors
install(TARGETS bsmtp DESTINATION "${bindir}")
install(TARGETS bsmtp DESTINATION "${sbindir}")
